<DOCTYPE html>
<!--HTML5 doctype-->
<html>
<head>
	<title>护理记录</title>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<link rel="stylesheet" type="text/css" href="../../css/jquery.mobile-1.4.0.css" />
	<link rel="stylesheet" type="text/css" href="../../css/zpdydhl_mobile.css">
	<link rel="stylesheet" type="text/css" href="../../css/mobiscroll.custom-2.6.2.min.css">
	<script type="text/javascript" src="../../js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.mobile-1.4.0.min.js"></script>
	<script type="text/javascript" src="../../js/zpdydhl_mobile.js"></script>
	<script type="text/javascript" src="../../js/mobiscroll.custom-2.6.2.min.js"></script>
</head>
<body>
	<div data-role="page" data-theme="c" id="page">
	 	
		<div>
		<style type="text/css">
		ul.hulijilu_list li{height:65px; border-bottom:1px solid #ccc;padding-top:10px;}
		ul.hulijilu_list li span.n1{float:left;margin-left:8px;display:block;width:89%;line-height:30px;color:#027fbd;}
		ul.hulijilu_list li span.n2{float:left;margin-left:8px;line-height:30px;}
		ul.hulijilu_list li span.n3{float:right;margin-right:8px;line-height:30px;}
		</style>
		<ul data-role="listview" class="hulijilu_list" style="min-height:500px;">
		</ul>
		</div>
		<div data-role="popup" id="selectWenshuType" data-overlay-theme="c" data-theme="c" data-dismissible="false" style="max-width:400px;">
			<div data-role="header" data-theme="a">
			<h1>添加记录或文书</h1>
			</div>
			<div role="main" class="ui-content wenshu_list" style="width:300px;padding-left:27px;">
			</div>
			<button style="color:black;" id="select_wenshu_cancel">取消</button>
		</div>
		<script type='text/javascript'>
		$(function () {
			zhuyuan_id = getRequestOne("patient_zhuyuan_id");
			huli_wenshu_type = decodeURI(getRequestOne("type"));
			document_type_global = "hulijilu";
			
		});
		function refreshData()
		{
			huliJilu();
			$(".ui-page").show();
		}
		$("#select_wenshu_cancel").die().live('click',function(){
			$("#selectWenshuType").popup('close');
		});
		//显示详细的护理文书
		$('.hulijilu_detail').die().live('click',function(){
			window.location.href="./editHuliwenshu.html?huliwenshu_id="+$(this).attr('huliwenshu_id')+"&type="+huli_wenshu_type;
		})
		//添加一条护理文书
		$("#add_hulijilu").die().live("click",function(){
			$.ajax({
				type: "get",
				async: true,
				url:server_url+"Mobile/HuliWenshu/showHuliWenshuJson"+yiyuan_id,
				data:{type:huli_wenshu_type},
				dataType: "jsonp",
				jsonp: "callbackShowHuliWenshuJson",
				jsonpCallback:"feedBackStateShowHuliWenshuJson",
				error:function(mes)
				{
					alert("请求失败，请稍后重试");
				},
				success: function(result) {
					if(result.ret =="success"){
						var str='';
						for(var i=0;i<result.data.length;i++)
						{
							str += '<a style="width:70%;margin:10px 0;" data href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-b selectWenshu" data-rel="back" data-transition="flow" muban_id="'+result.data[i].id+'" muban_name="'+result.data[i].title+'">'+result.data[i].title+'</a>';
						}
						$(".wenshu_list").html(str);
						$("#selectWenshuType").popup('open');
					}
					else{
						alert("未连接至服务器，请查看网络");
					}
				}
			});

		});
		$('.selectWenshu').die().live('vmousedown',function(){
			this_muban_id= $(this).attr("muban_id");
			this_muban_name = $(this).attr("muban_name");
			if(confirm("确定添加"+this_muban_name+"？"))
			{
				$.ajax({
					type: "get",
					async: false,
					url:server_url+"Mobile/HuliJilu/addHuliwenshuHulijilu"+yiyuan_id,
					data: {zhuyuan_id:patient_info_global.zhuyuan_id,user_number:nurse_info_global.user_number,muban_id:this_muban_id},
					dataType: "jsonp",
					jsonp: "callbackAddHuliwenshuHulijilu",
					jsonpCallback:"feedBackStateAddHuliwenshuHulijilu",
					error:function(mes)
					{
						alert(mes);
					},
					success: function(result) {
						if(result.ret=="success")
							huliJilu();
						else
							alert("添加失败");
					}
				});
				$("#selectWenshuType").popup('close');
			}
		})
		//显示护理记录文书列表
		function huliJilu(){
			/*
			*huli_wenshu_type 护理记录类型
			*all 所有的 筛选传文书的标题
			*/
			//setHeader();
			$.ajax({
				type: "get",
				async: false,
				url:server_url+"Moblie/HuliJilu/showListJson"+yiyuan_id,
				data: {zhuyuan_id:patient_info_global.zhuyuan_id,huli_wenshu_type:huli_wenshu_type,user_number:nurse_info_global.user_number},
				dataType: "jsonp",
				jsonp: "callbackShowListJson",
				jsonpCallback:"feedBackStateShowListJson",
				error:function(mes)
				{
					alert(mes);
				},
				success: function(result) {
					
					if(result.ret=="success")
					{
						var str = '';
						if(result.data != 'empty')
						{
							for(var i=0;i<result.data.length;i++)
							{
									str +='<li class="hulijilu_detail" huliwenshu_id="'+result.data[i].id+'">'+
										  '<span class="n1">'+result.data[i].bingli_title+'</span>'+
										  '<span class="n2">添加者:'+result.data[i].create_user_name+'</span>'+
										  '<span class="n3">时间:'+result.data[i].create_time+'</span></li>'; 
							}
						}
						$('.hulijilu_list').html(str);
					}
					else
						alert("失败");
				}
			});
		}
		</script>
	</div>
</body>
</html>